using System.Data.Linq;
using System.Data.Linq.Mapping;
using MirrorMirror;

namespace Magiq.Providers.Entities.Support
{
    public class EntitySetAdapter
    {
        public EntitySetAdapter(object objectThatShouldBeAnEntitySet)
        {
            EntitySet = objectThatShouldBeAnEntitySet;
            var source = objectThatShouldBeAnEntitySet.Get("source");
            Instance = source.Get("instance");
            var factory = source.Get("factory");
            Member = factory.Get<MetaDataMember>("member");
            DataContext = factory.Get<DataContext>("services.Context");
        }

        public object EntitySet { get; private set; }
        public object Instance { get; private set; }
        public DataContext DataContext { get; private set; }
        public MetaDataMember Member { get; private set; }
    }
}